home *** CD-ROM | disk | FTP | other *** search
- TITLE ** CXR DETECT MONITOR / RESET FOR FIDO **
- page 55,132
- name CDMON
-
- ; *********************************************
- ; CDMON - Carrier Detect (DCD) Monitoring
- ; and Watchdog Program.
- ;
- ; CDMON program for monitoring COM1 and COM2
- ; Cxr Detect signals (IBM PC) and resetting
- ; system to warm boot if carrier lost.
- ;
- ; Author: M. E. Zilmer / Soft Systems Assoc.
- ; This program is licensed for public domain
- ; use. Commercial use is prohibited without
- ; permission. Direct inquiries to:
- ;
- ; Matthew E. Zilmer
- ; Soft Systems Associates
- ; 919 W. Baseline Rd.
- ; Claremont, CA. 91711-1508
- ;
- ; MASM 2.0 recommended as Macro-Assembler.
- ;
- ; -------------------------------------------------
- ; : 1.00 MEZ Base Line Release (COM1, DCD=x20) :
- ; : 1.10 MEZ Update to command line args for :
- ; : COM port, DCD mask, drop timer. :
- ; -------------------------------------------------
- ;
- ; ************************************************************************
- ;
- ; 1.1 - available on the cmd line in the following format ...
- ;
- ; CDMON C/[com] M/[mask] T/[ticks]
- ;
- ; where com = 1 or 2 to indicate COM1 or COM2
- ; <default = COM1>,
- ;
- ; mask = xxx your DCD mask value <default = 128>
- ; limit is 128,
- ;
- ; ticks = yyy timer ticks over which DCD can drop
- ; without warm start occurring
- ; <default = 27 or 1.5 Seconds>.
- ; limit is 255.
- ;
- ; example:
- ;
- ; CDMON C/1 M/128 T/10 ; COM1, mask = 128.
- ; ; DCD drop time = 10 ticks (550 mS).
- ;
- ; Not all options must be specified, however, any options used must
- ; be in the order stated above.
- ;
- ; ***********************************************************************
-
- MSR2 equ 2feH ; modem status reg for COM2.
-
- MSR1 equ 3feH ; modem status reg for COM1.
-
- DCDD equ 128 ; Data CXR Detect mask bit.
- ; (128 for Hayes, USR Courier).
-
- TIMEOUT equ 275 ; default timeout millisecond count.
-
- page
-
- startup segment at 0ffffH
- restart label far ; reboot location.
- startup ends
-
- vectors segment at 0
- org 1ch*4
- aux_vec dw 2 dup (?) ; aux timer vector.
- vectors ends
-
- data segment at 40h
- org 72h
- reset_flag db ? ; reboot flag.
- data ends
-
- page
-
- code segment public 'code'
- assume cs:code, ds:code, es:code, ss:nothing
-
- org 100H
-
- start:
- jmp begin
-
- no_dcd db 0
- msr dw MSR1 ; default is COM1.
- dcd db DCDD ; default mask bit.
- limit db TIMEOUT / 55 ; ticks for DCD drop reset.
- accum dw 0 ; accum for get_dec_byte.
-
- page
-
- cxr_look proc far ; monitor DCD line.
-
- push ds
- push dx
- push ax ; save machine state.
- mov dx,cs
- mov ds,dx
- mov dx,msr ; look at modem status register.
- in al,dx
- and al,dcd ; test modem status for DCD. (act. DSR).
-
- jnz cl_0
- inc no_dcd ; increment carrier drop timer.
- jmp short cl_1 ; finish up - check drop count.
- cl_0:
- mov no_dcd,0
- pop ax
- pop dx
- pop ds
- iret
- cl_1:
- mov al,limit
- cmp no_dcd,al ; check drop count for X Ticks.
- je reset
- pop ax
- pop dx
- pop ds
- iret ; return control.
- reset:
- mov ax, data ; set low RAM data segment.
-
- assume ds:data
-
- mov ds, ax
- mov bx, offset reset_flag
- mov word ptr [bx],1234H ; set warm boot flag.
- jmp far ptr restart ; restart.
-
- cxr_look endp
-
- db ' Soft Systems - CDMON v1.1',0 ; signature.
-
- code_end label byte
-
- db 10h dup (0)
-
- page
-
- ; The code past 'code_end' is thrown away since it is never needed
- ; again.
-
- inimsg db ' CDMON v 1.1 - Carrier Drop Protect',0dh,0ah
- db ' Copyright (C)1985 Soft Systems Associates',0dh,0ah
- db ' Licensed for non-commercial and Public Domain use',0dh,0ah
- db ' and distribution. COM'
- pmsg db '1 is being monitored',0dh,0ah,0ah,'$'
-
- assume ds:code
-
- begin proc near
- mov ax,cs
- mov ds,ax
- mov es,ax
- push ds
-
- assume ds:vectors
-
- mov ax,vectors
- mov ds,ax
- mov bx,offset aux_vec ; intercept aux timer tick int.
- mov word ptr [bx],offset cxr_look
- mov [bx+2],cs ; set vector to point at our code.
- pop ds
-
- ; get command line args. set msr, dcd and ticks accordingly.
-
- assume ds:code
-
- mov bx,80h ; get char count after 'CDMON'.
- mov cl,[bx]
- xor ch,ch
- inc bx
- call nxnd ; next non-delimiter.
- jc no_cla ; no cmd line args found.
-
- ; now see what that arg is ....
-
- mov ax,[bx] ; get that word.
- or al,20H ; make lower.
- cmp ax,'/c' ; COM port arg ?
- jne cla2a ; check next.
- inc bx
- inc bx
- cmp byte ptr [bx],'1' ; COM1?
- jne cla1
- jmp short cla2
- cla1:
- cmp byte ptr [bx],'2' ; COM2?
- jne cla2
- mov msr,MSR2 ; set MSR port accordingly.
- mov pmsg,ah ; put in monitoring msg.
- cla2:
- mov dx,offset inimsg ; print banner.
- mov ah,9 ; print string fc.
- int 21h
-
- call nxd ; get to next delimiter.
- cmp cx,0 ; see if out of chars.
- je no_cla
- call nxnd ; next non-delim.
- cmp cx,0
- je no_cla ; no change, mask is DCDD.
- cla2a:
- mov ax,[bx]
- or al,20H ; make lower.
- cmp ax,'/m' ; see if mask parm.
- jne cla3a ; check Timer, now.
- inc bx ; pass 'm/' up, get binary.
- inc bx
- call get_dec_byte ; convert to binary.
- mov dcd,al ; put in as mask.
- call nxd
- jc no_cla
- call nxnd
- jc no_cla
- mov ax,[bx]
- or al,20H
- cla3a:
- cmp ax,'/t' ; see if ticks specified.
- jne no_cla
- inc bx
- inc bx
- call get_dec_byte
- mov limit,al
-
- no_cla:
- mov dx,offset code_end+10h
- int 27h ; fully compatible KEEP call.
- ; terminate and stay resident.
-
- ; that's all folks !!
-
- begin endp
- page
-
- nxd proc near ; find next [bx] delimiter.
-
- cmp byte ptr [bx],' ' ; blank?
- je nxd1 ; found delim.
- cmp byte ptr [bx],',' ; comma.
- je nxd1
- cmp byte ptr [bx],0dh ; cr or lf.
- je nxd1
- cmp byte ptr [bx],0ah
- je nxd1
- dec cx ; decr count.
- jnz nxd0 ; next char.
- stc ; count exhausted.
- ret
- nxd0:
- inc bx
- jmp nxd
- nxd1:
- clc
- ret
-
- nxd endp
-
- nxnd proc near ; find next [bx] non-delimiter.
-
-
- cmp byte ptr [bx],' ' ; blank?
- je nxnd0 ; found delim.
- cmp byte ptr [bx],',' ; comma.
- je nxnd0
- cmp byte ptr [bx],0dh ; cr or lf.
- je nxnd0
- cmp byte ptr [bx],0ah
- clc ; found a delimiter.
- ret
- nxnd0:
- inc bx
- dec cx
- jnz nxnd ; count is exhausted.
- stc
- ret
-
- nxnd endp
- page
-
- n100 dw 100
- n10 dw 10
-
- get_dec_byte proc near ; translate ascii decimal
- ; at bx to binary byte in al.
-
- push bx
- mov accum,0 ; zero accumulator.
- push bx
- mov si,bx
- call nxd ; find end + 1.
- pop di
- sub bx,di ; find length of decimal.
- jne gdb_nz
- mov al,0 ; zero length = 0.
- pop bx
- ret
- gdb_nz:
- dec bx
- je gdb_2 ; length = 1, units only.
- dec bx
- je gdb_1 ; length = 2, tens, units.
- dec bx
- je gdb_0 ; length = 3, 100's, tens, units.
- mov al,0ffh ; max byte length.
- pop bx
- ret
- gdb_0:
- mov al,[si] ; do 100's.
- call make_bin
- xor ah,ah
- mul cs:n100
- add accum,ax
- inc si
- gdb_1:
- mov al,[si] ; do 10's.
- call make_bin
- xor ah,ah
- mul cs:n10
- add accum,ax
- inc si
- gdb_2:
- mov al,[si] ; do 1's.
- call make_bin
- xor ah,ah
- add ax,accum
- pop bx
- ret
-
- get_dec_byte endp
-
- make_bin proc near ; make binary from [bx] char.
-
- sub al,'0'
- cmp al,9
- ja mb_0
- ret
- mb_0:
- sub al,7
- ret
-
- make_bin endp
-
- code ends
- end start
-